package com.wwwarehouse.resource_center.fragment.productiontools;


import android.app.Dialog;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.wwwarehouse.common.activity.base.BaseFragment;
import com.wwwarehouse.common.custom_widget.time_pick.ChoosePickerDialog;
import com.wwwarehouse.common.tools.DialogTools;
import com.wwwarehouse.resource_center.R;
import com.wwwarehouse.resource_center.constant.ResourceConstant;

import java.util.ArrayList;
import java.util.List;

/**
 * Creator by zhenwang.xiang on 2017/11/23 10:24
 * Description: 录入生产工具主界面
 */

@Route(path = ResourceConstant.PATH_INPUT_GENERATION_TOOL_FRAGMENT)
public class InputGenerationToolFragment extends BaseFragment implements View.OnClickListener {

    private TextView mSelectUnit, mSelectWarseHouse;
    private List<String> mSelectUnitData;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_input_generation_tool, container, false);
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        initView();
    }

    private void initView() {
        mSelectUnit = $(R.id.tv_unit);
        mSelectWarseHouse = $(R.id.tv_select_warhouse);
        mSelectUnit.setOnClickListener(this);
        $(R.id.ll_property_name).setOnClickListener(this);
        $(R.id.ll_department_warhouse).setOnClickListener(this);
        $(R.id.ll_category).setOnClickListener(this);
        $(R.id.ll_attribute).setOnClickListener(this);
    }

    @Override
    public void setTitle() {

    }

    @Override
    public void requestDatas() {

    }

    @Override
    public void onClick(View v) {
        int id = v.getId();
        if (id == R.id.ll_property_name) {
        } else if (id == R.id.tv_unit) {
            mSelectUnitData = new ArrayList<>();
            mSelectUnitData.add("千克");
            mSelectUnitData.add("米");
            mSelectUnitData.add("吨");
            mSelectUnitData.add("克");
            mSelectUnitData.add("厘米");
            new ChoosePickerDialog.Builder(getActivity()).setTitle("选择单位").setData(mSelectUnitData).setOnDataSelectedListener(new ChoosePickerDialog.OnSelectedListener() {
                @Override
                public void onSelected(String itemValue, int position) {
                    mSelectUnit.setText(itemValue);
                }

                @Override
                public void onCancel() {

                }
            }).create().show();

        } else if (id == R.id.ll_department_warhouse) {
            mSelectUnitData = new ArrayList<>();
            mSelectUnitData.add("下沙仓");
            mSelectUnitData.add("贝克仓");
            mSelectUnitData.add("萧山仓");
            mSelectUnitData.add("瓜沥仓");
            mSelectUnitData.add("京华仓");
            new ChoosePickerDialog.Builder(getActivity()).setTitle("选择要录入设备的仓库").setData(mSelectUnitData).setOnDataSelectedListener(new ChoosePickerDialog.OnSelectedListener() {
                @Override
                public void onSelected(String itemValue, int position) {
                    mSelectWarseHouse.setText(itemValue);
                }

                @Override
                public void onCancel() {

                }
            }).create().show();

        } else if (id == R.id.ll_category) {
            DialogTools.getInstance().showTCDialog(getActivity(), "提示", "返回将不保存已输入内容，仍要返回吗？", "再等等", "不保存，返回", new DialogTools.ConfirmListener() {
                @Override
                public void setConfirmListener(Dialog dialog, View view, String input) {

                }
            }, new DialogTools.DismissListener() {
                @Override
                public void setDismissListener(Dialog dialog, View view) {

                }
            });
        } else if (id == R.id.ll_attribute) {
        } else {
        }
    }
}
